package com.wing.cabinet.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.cabinet.dao.ReceiveRecordDao;
import com.wing.cabinet.model.entity.ReceiveRecord;
import com.wing.cabinet.model.request.ReceiveRecordForm;
import com.wing.cabinet.model.response.ReceiveRecordVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 领取记录表-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class ReceiveRecordServiceImpl extends ServiceImpl<ReceiveRecordDao, ReceiveRecord> implements ReceiveRecordService {

    @Override
    public int add(ReceiveRecordForm receiveRecordForm) {

        //校验

        ReceiveRecord receiveRecord =new ReceiveRecord();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(ReceiveRecord.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(receiveRecordForm, receiveRecord, copyOptions);

        return baseMapper.insert(receiveRecord);
    }

    @Override
    public List<ReceiveRecordVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<ReceiveRecordVO> pageList4app(Page page, Map<String, Object> params) {
        List<ReceiveRecordVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public ReceiveRecordVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }

    @Override
    public Double sumByTotalMoney(Long authorityManageId,String todayTime,String skuCode) {
        return baseMapper.sumByTotalMoney(authorityManageId,todayTime,skuCode);
    }

    @Override
    public Integer sumByTotalQuantity(Long authorityManageId, String todayTime) {
        return baseMapper.sumByTotalQuantity(authorityManageId,todayTime);
    }

    @Override
    public Integer sumByTotalQuantityOne(Long authorityManageId, String todayTime,String skuCode) {
        return baseMapper.sumByTotalQuantityOne(authorityManageId,todayTime,skuCode);
    }

    @Override
    public Double sumMoney(Long authorityManageId,String startTime, String endTime,String skuCode) {
        return baseMapper.sumMoney(authorityManageId,startTime,endTime,skuCode);
    }

    @Override
    public Integer sumQuantity(Long authorityManageId, String startTime, String endTime) {
        return baseMapper.sumQuantity(authorityManageId,startTime,endTime);
    }
    @Override
    public Integer sumQuantityOne(Long authorityManageId, String startTime, String endTime,String skuCode) {
        return baseMapper.sumQuantityOne(authorityManageId,startTime,endTime,skuCode);
    }

    @Override
    public Double sumIndependentByTotalMoney(Long authorityManageId,Long receiverId, String todayTime,String skuCode) {
        return baseMapper.sumIndependentByTotalMoney(authorityManageId,receiverId,todayTime,skuCode);
    }

    @Override
    public Double sumIndependentMoneyByReceiverId(Map<String, Object> params) {
        return baseMapper.sumIndependentMoneyByReceiverId(params);
    }

    @Override
    public ReceiveRecordVO getIntraDayReceiveRecordByParams(Map<String, Object> params) {
        return baseMapper.getIntraDayReceiveRecordByParams(params);
    }

    @Override
    public ReceiveRecordVO getReceiveRecordByParams(Map<String, Object> params) {
        return baseMapper.getReceiveRecordByParams(params);
    }

    @Override
    public Integer sumIndependentByTotalQuantity(Long authorityManageId, Long receiverId, String todayTime) {
        return baseMapper.sumIndependentByTotalQuantity(authorityManageId,receiverId,todayTime);
    }
    @Override
    public Integer sumIndependentByTotalQuantityOne(Long authorityManageId, Long receiverId, String todayTime,String skuCode) {
        return baseMapper.sumIndependentByTotalQuantityOne(authorityManageId,receiverId,todayTime,skuCode);
    }

    @Override
    public Integer sumIndependentQuantityByReceiverId(Map<String, Object> params) {
        return baseMapper.sumIndependentQuantityByReceiverId(params);
    }
}
